package com.hcf.project.controller;

import com.hcf.project.common.convention.result.Result;
import com.hcf.project.common.convention.result.ResultTool;
import com.hcf.project.service.UrlTitleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Url标题控制层
 */
@RestController
@RequestMapping("/api/shortlink")
public class UrlTitleController {

    @Autowired
    private UrlTitleService urlTitleService;

    /**
     * 根据URL获取对应网站的标题
     * @param url
     * @return
     */
    @RequestMapping("/title")
    public Result<String> getUrlTitle(@RequestParam("url") String url) {

        return ResultTool.success(urlTitleService.getUrlTitle(url));
    }

}
